package com.bawei.module_home.adapter

import android.annotation.SuppressLint
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.bawei.module_home.databinding.HourseItemBinding
import com.bawei.module_home.databinding.HousemanageItemBinding
import com.bawei.module_home.model.HomeServiceModel
import com.bawei.module_home.model.HouseItem


class HouseManageAdapter(): RecyclerView.Adapter<HouseManageAdapter.HouseViewHolder>() {

    val housemanageList= mutableListOf<HouseItem>()

    class HouseViewHolder(item:HousemanageItemBinding):RecyclerView.ViewHolder(item.root){}

    @SuppressLint("SuspiciousIndentation")
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HouseViewHolder {

      val binding=HousemanageItemBinding.inflate(
          LayoutInflater.from(parent.context)
          ,parent,
          false
      )
        return HouseViewHolder(binding)
    }

    override fun getItemCount(): Int {
      return housemanageList.size
    }

    override fun onBindViewHolder(holder: HouseViewHolder, position: Int) {
        val binding=DataBindingUtil.getBinding<HousemanageItemBinding>(holder.itemView)
        binding?.housemagainName?.text=housemanageList[position].enterpriseName
        binding?.housemagainAddress?.text=housemanageList[position].regionName

    }

    fun setData(data:List<HouseItem>){
        housemanageList.clear()
        housemanageList.addAll(data)
        notifyDataSetChanged()
    }


}